if __name__ == '__main__':
    from threading import Thread
    from queue import Queue
    import time
    queue = Queue(5)
    class producer(Thread):
        def __init__(self,name,count,queue):
            super().__init__()
            self.name = name
            self.count = count
            self.queue  = queue
        def run(self) -> None:
            for i in range(self.count):
                msg = f"{self.name}-{i}"
                self.queue.put(msg,block=True)

    class consumer(Thread):
        def __init__(self, name, queue):
            super().__init__()
            self.name = name
            self.queue = queue
            self.daemon = True
        def run(self) -> None:
            while True:
                time.sleep(0.2)
                msg = self.queue.get(block=True)
                print(f"{self.name}-{msg}\n",end='')


    threads = list()
    threads.append(producer('producer01', 10, queue))
    threads.append(producer('producer02', 10, queue))
    threads.append(consumer('consumer01', queue))
    threads.append(consumer('consumer02', queue))
    for thread in threads:
        thread.start()